package com.zggk.framework.controller.score;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.platform.common.utils.JsonUtils;
import com.platform.common.utils.PageUtils;
import com.platform.framework.controller.BaseController;
import com.zggk.framework.entity.score.GjContentcomm;
import com.zggk.framework.entity.score.GjContenthigh;
import com.zggk.framework.service.score.GjContentcommService;
import com.zggk.framework.service.score.GjContenthighService;
import com.zggk.framework.service.score.GjGradeService;

/**
 * @Description 检查记录控制层
 * @author 张立增
 * @Date 2020年2月27日 上午11:20:23
 */
@RestController
@RequestMapping("/checkRecord")
public class CheckRecordController extends BaseController {

	@Autowired
	GjContentcommService gjContentcommService;

    @Autowired
    GjContenthighService gjContenthighService;
    
    @Autowired
    GjGradeService gjGradeService;
    
	/**
	* @Description 跳转到检查记录页面的方法
	* @author 张立增[zhanglizeng] Tel：18860126570
	* @createDate 2020-02-26 11:30:46
	*/
    @RequestMapping(value = "/index")
	public ModelAndView index() {
		ModelAndView mv = new ModelAndView("score/checkRecord/index");
		return mv;
	}
    
    /**
	 * @Description 得到数列表
	 * @author 张立增
	 * @Date 2020年2月26日 下午8:22:12
	 */
	@RequestMapping(value = "/getTreeGridData",method= {RequestMethod.POST})  
	public String getTreeGridData(HttpServletRequest request) throws Exception {   
		String roadType = request.getParameter("roadType"); 
		if("H".equals(roadType)) {    //高速
			return gjContenthighService.getTreeGridData();
		}else {//普通
			return gjContentcommService.getTreeGridData();
		}
	}
	
	/**
	 * @Description 得到列表数据
	 * @author 张立增
	 * @Date 2020年2月26日 下午9:44:26
	 */
	@RequestMapping(value="/getDataGridByPid",method= {RequestMethod.POST,RequestMethod.GET})
	public String getDataGridByPid(HttpServletRequest request) throws Exception{
		String pid = request.getParameter("pid"); 
		String roadType = request.getParameter("roadType"); 
		Pageable pageable = null;    
		try {
			pageable = PageUtils.dealminiRequest(request);
		} catch (Exception e) {
			e.printStackTrace();
		}
		if("H".equals(roadType)) {    //高速
			Page<GjContenthigh> pages = gjContenthighService.getDataGridByPid(pid,pageable);
			return JsonUtils.dealMiniPage(pages);
		}else {//普通
			Page<GjContentcomm> pages = gjContentcommService.getDataGridByPid(pid,pageable);
			return JsonUtils.dealMiniPage(pages);
		}
	}
	
	/**
	 * @Description 得到一个编号的详细信息，包括评分
	 * @author 张立增
	 * @Date 2020年2月29日 下午6:20:46
	 */
	@RequestMapping(value = "/getOneDetailData",method= {RequestMethod.POST})  
	public String getOneDetailData(HttpServletRequest request) throws Exception {   
		String roadType = request.getParameter("roadType"); 
		String id = request.getParameter("id"); 
		String pid = request.getParameter("pid"); 
		if("H".equals(roadType)) {    //高速
			return gjContenthighService.getOneDetailData(id,pid);
		}else {//普通
			return gjContentcommService.getOneDetailData(id,pid);
		}
	}
	
	
	
	
	
	
}
